<?php
require_once('functions.php');
session_start();
function doLogIn($email, $password)
{ 
	$conn = getConnection();
    $sqlUsers = "SELECT * FROM 2011_Users WHERE Password = '$password'";        
    $resultUsers = $conn->query($sqlUsers);
	$rsUser = $resultUsers->fetch_assoc();
    if($rsUser['Password'] == $password)
    {
    	$sqlCM = "SELECT * FROM 2011_ContactMethods WHERE Email = '$email'";
    	$resultCM = $conn->query($sqlCM);
    	$rsCM = $resultCM->fetch_assoc();
    	$conn->close();
    	if ($rsCM['Email'] == $email) {
    		$_SESSION['UserId'] = $rsUser['id'];
    		$_SESSION['UserEmail'] = $rsCM['Email'];
    		$_SESSION['UserName'] = $rsUser['FirstName'];
    	}
   }
}
function isLoggedIn()
{
        return isset($_SESSION['UserId']);
}
function getUserName()
{
        return $_SESSION['UserName'];
}
function getUserId()
{
        return $_SESSION['UserId'];
}
function getUserEmail()
{
        return $_SESSION['UserEmail'];
}
function doLogOut()
{
        session_destroy();
}
?>

